home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 20 / macformat_20.iso / mac / Shareware / Desarrolladores / Sprite Animation Toolkit 2.3.8 / Demos / FastLoad Demo ƒ / FastLoadDemo.p < prev   
Text File  |  1996-06-23  |  2KB  |  78 lines

  1. program FastLoadDemo;
  2.  
  3. {A demo/test program showing how to load a large number of faces from PICT resources with}
  4. {minimal overhead. There are some parts missing - row start tables to be precise - and you}
  5. {could possibly take the mask regions out. It all depends on your needs. If you plan to use SAT's}
  6. {blitters all the time (i.e. SATRun(true) you can remove the regions.}
  7.  
  8. {This program will ONLY work in 256 colors or more! In B/W or 4-bit color, there are additional}
  9. {data needed since SAT does certain special optimizing for those depths. I have tested it in 256}
  10. {and thousands of colors, and it will probably run out of memory in millions.}
  11.  
  12. {This program does no error checking! You will have to add that to use it in a real program!}
  13.  
  14. {/Ingemar Ragnemalm december 1995}
  15. {Revised may 1996, in order to clean up, add more options, and make FaceLoad a stand-alone}
  16. {reusable module.}
  17.  
  18.     uses
  19. {$ifc UNDEFINED THINK_PASCAL}
  20.         Types, QuickDraw, Events, Windows, Dialogs, Fonts, DiskInit, TextEdit, Traps,{}
  21.         Memory, SegLoad, Scrap, ToolUtils, OSUtils, Menus, Resources, StandardFile,{}
  22.         GestaltEqu, Files, Errors, Devices, 
  23. {$endc}
  24.         SAT, FastLoad;
  25.  
  26.     var
  27.         ppsprite: Sprite;
  28.         sptr: SpritePtr;
  29.  
  30.         faces: FaceArrPtr;
  31.         h, v: Integer;
  32.  
  33.     procedure Nop (me: SpritePtr);
  34.     begin
  35.     end;
  36.  
  37. begin
  38. {$IFC UNDEFINED THINK_PASCAL}
  39.     SATInitToolbox;
  40. {$ENDC}
  41.  
  42.     SATInit(128, 128, 400, 300);
  43.  
  44. {Load the faces!}
  45.     SysBeep(1);
  46.     faces := Load2DFaceArray(129, 130, 100, 32, 32, 10, true, true);
  47.     SysBeep(1);
  48.  
  49. {I use SATNewSpritePP here. That has no connection to the face loading - I could just as well}
  50. {use SATNewSprite as usual! Consider this a little demonstration of SATNewSpritePP thrown in}
  51. {"for free".}
  52.     sptr := SATNewSpritePP(nil, @ppsprite, 0, 0, 0, nil);
  53.     ppsprite.task := @Nop;
  54.     ppsprite.face := nil;
  55.  
  56.     SATSetPortScreen;
  57.     HideCursor;
  58.     while not Button do
  59.         begin
  60. {Set the face of the sprite to one of the 100 sprites in the faces array, depending on mouse position.}
  61.             GetMouse(ppsprite.position);
  62.  
  63.             h := ppsprite.position.h * 10 div gSAT.offSizeH;
  64.             if h < 0 then
  65.                 h := 0;
  66.             if h > 9 then
  67.                 h := 9;
  68.             v := ppsprite.position.v * 10 div gSAT.offSizeV;
  69.             if v < 0 then
  70.                 v := 0;
  71.             if v > 9 then
  72.                 v := 9;
  73.             ppsprite.face := @faces^[h + v * 10];
  74.  
  75.             SATRun(false);
  76.         end;
  77.     ShowCursor;
  78. end.